import { query } from '../services/warehouse';

export default {
  namespace: 'warehouse',
  state: {},
  effects: {
    *getWarehouse({ payload }, { call, put }) {
      const { data: { message, warehouse } } = yield call(query);
      message === 'success' ? payload.success() : payload.failed();
      yield put({ type: 'update', data: warehouse });
    }
  },
  reducers: {
    update(state, action) {
      return { ...state, data: action.data };
    }
  }
}